<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveRecord::Migration</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveRecord::Migration</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/rails/activerecord/lib/active_record/migration_rb.html">
                vendor/rails/activerecord/lib/active_record/migration.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Migrations can manage the evolution of a schema used by several physical
databases. It&#8216;s a solution to the common problem of adding a field to
make a new feature work in your local database, but being unsure of how to
push that change to other developers and to the production server. With
migrations, you can describe the transformations in self-contained classes
that can be checked into version control systems and executed against
another database that might be one, two, or five versions behind.
</p>
<p>
Example of a simple migration:
</p>
<pre>
  class AddSsl &lt; ActiveRecord::Migration
    def self.up
      add_column :accounts, :ssl_enabled, :boolean, :default =&gt; 1
    end

    def self.down
      remove_column :accounts, :ssl_enabled
    end
  end
</pre>
<p>
This migration will add a boolean flag to the accounts table and remove it
if you&#8216;re backing out of the migration. It shows how all migrations
have two class methods <tt>up</tt> and <tt>down</tt> that describes the
transformations required to implement or remove the migration. These
methods can consist of both the migration specific methods like add_column
and remove_column, but may also contain regular Ruby code for generating
data needed for the transformations.
</p>
<p>
Example of a more complex migration that also needs to initialize data:
</p>
<pre>
  class AddSystemSettings &lt; ActiveRecord::Migration
    def self.up
      create_table :system_settings do |t|
        t.string  :name
        t.string  :label
        t.text  :value
        t.string  :type
        t.integer  :position
      end

      SystemSetting.create :name =&gt; &quot;notice&quot;, :label =&gt; &quot;Use notice?&quot;, :value =&gt; 1
    end

    def self.down
      drop_table :system_settings
    end
  end
</pre>
<p>
This migration first adds the system_settings table, then creates the very
first row in it using the Active Record model that relies on the table. It
also uses the more advanced create_table syntax where you can specify a
complete table schema in one block call.
</p>
<h2>Available transformations</h2>
<ul>
<li><tt>create_table(name, options)</tt> Creates a table called <tt>name</tt>
and makes the table object available to a block that can then add columns
to it, following the same format as add_column. See example above. The
options hash is for fragments like &quot;DEFAULT CHARSET=UTF-8&quot; that
are appended to the create table definition.

</li>
<li><tt>drop_table(name)</tt>: Drops the table called <tt>name</tt>.

</li>
<li><tt>rename_table(old_name, new_name)</tt>: Renames the table called
<tt>old_name</tt> to <tt>new_name</tt>.

</li>
<li><tt>add_column(table_name, column_name, type, options)</tt>: Adds a new
column to the table called <tt>table_name</tt> named <tt>column_name</tt>
specified to be one of the following types: <tt>:string</tt>,
<tt>:text</tt>, <tt>:integer</tt>, <tt>:float</tt>, <tt>:decimal</tt>,
<tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>, <tt>:date</tt>,
<tt>:binary</tt>, <tt>:boolean</tt>. A default value can be specified by
passing an <tt>options</tt> hash like <tt>{ :default =&gt; 11 }</tt>. Other
options include <tt>:limit</tt> and <tt>:null</tt> (e.g. <tt>{ :limit =&gt;
50, :null =&gt; false }</tt>) &#8212; see
ActiveRecord::ConnectionAdapters::TableDefinition#column for details.

</li>
<li><tt>rename_column(table_name, column_name, new_column_name)</tt>: Renames a
column but keeps the type and content.

</li>
<li><tt>change_column(table_name, column_name, type, options)</tt>: Changes the
column to a different type using the same parameters as add_column.

</li>
<li><tt>remove_column(table_name, column_name)</tt>: Removes the column named
<tt>column_name</tt> from the table called <tt>table_name</tt>.

</li>
<li><tt>add_index(table_name, column_names, options)</tt>: Adds a new index
with the name of the column. Other options include <tt>:name</tt> and
<tt>:unique</tt> (e.g. <tt>{ :name =&gt; &quot;users_name_index&quot;,
:unique =&gt; true }</tt>).

</li>
<li><tt>remove_index(table_name, index_name)</tt>: Removes the index specified
by <tt>index_name</tt>.

</li>
</ul>
<h2>Irreversible transformations</h2>
<p>
Some transformations are destructive in a manner that cannot be reversed.
Migrations of that kind should raise an
<tt>ActiveRecord::IrreversibleMigration</tt> exception in their
<tt>down</tt> method.
</p>
<h2>Running migrations from within <a href="../Rails.html">Rails</a></h2>
<p>
The <a href="../Rails.html">Rails</a> package has several tools to help
create and apply migrations.
</p>
<p>
To generate a new migration, you can use
</p>
<pre>
  script/generate migration MyNewMigration
</pre>
<p>
where MyNewMigration is the name of your migration. The generator will
create an empty migration file <tt>nnn_my_new_migration.rb</tt> in the
<tt>db/migrate/</tt> directory where <tt>nnn</tt> is the next largest
migration number.
</p>
<p>
You may then edit the <tt>self.up</tt> and <tt>self.down</tt> methods of
MyNewMigration.
</p>
<p>
There is a special syntactic shortcut to generate migrations that add
fields to a table.
</p>
<pre>
  script/generate migration add_fieldname_to_tablename fieldname:string
</pre>
<p>
This will generate the file <tt>nnn_add_fieldname_to_tablename</tt>, which
will look like this:
</p>
<pre>
  class AddFieldnameToTablename &lt; ActiveRecord::Migration
    def self.up
      add_column :tablenames, :fieldname, :string
    end

    def self.down
      remove_column :tablenames, :fieldname
    end
  end
</pre>
<p>
To run migrations against the currently configured database, use <tt>rake
db:<a href="Migration.html#M001667">migrate</a></tt>. This will update the
database by running all of the pending migrations, creating the
<tt>schema_migrations</tt> table (see &quot;About the schema_migrations
table&quot; section below) if missing.
</p>
<p>
To roll the database back to a previous migration version, use <tt>rake
db:<a href="Migration.html#M001667">migrate</a> VERSION=X</tt> where
<tt>X</tt> is the version to which you wish to downgrade. If any of the
migrations throw an <tt>ActiveRecord::IrreversibleMigration</tt> exception,
that step will fail and you&#8216;ll have some manual work to do.
</p>
<h2>Database support</h2>
<p>
Migrations are currently supported in MySQL, PostgreSQL, SQLite, SQL
Server, Sybase, and Oracle (all supported databases except DB2).
</p>
<h2>More examples</h2>
<p>
Not all migrations change the schema. Some just fix the data:
</p>
<pre>
  class RemoveEmptyTags &lt; ActiveRecord::Migration
    def self.up
      Tag.find(:all).each { |tag| tag.destroy if tag.pages.empty? }
    end

    def self.down
      # not much we can do to restore deleted data
      raise ActiveRecord::IrreversibleMigration, &quot;Can't recover the deleted tags&quot;
    end
  end
</pre>
<p>
Others remove columns when they <a
href="Migration.html#M001667">migrate</a> up instead of down:
</p>
<pre>
  class RemoveUnnecessaryItemAttributes &lt; ActiveRecord::Migration
    def self.up
      remove_column :items, :incomplete_items_count
      remove_column :items, :completed_items_count
    end

    def self.down
      add_column :items, :incomplete_items_count
      add_column :items, :completed_items_count
    end
  end
</pre>
<p>
And sometimes you need to do something in SQL not abstracted directly by
migrations:
</p>
<pre>
  class MakeJoinUnique &lt; ActiveRecord::Migration
    def self.up
      execute &quot;ALTER TABLE `pages_linked_pages` ADD UNIQUE `page_id_linked_page_id` (`page_id`,`linked_page_id`)&quot;
    end

    def self.down
      execute &quot;ALTER TABLE `pages_linked_pages` DROP INDEX `page_id_linked_page_id`&quot;
    end
  end
</pre>
<h2>Using a model after changing its table</h2>
<p>
Sometimes you&#8216;ll want to add a column in a migration and populate it
immediately after. In that case, you&#8216;ll need to make a call to <a
href="Base.html#M001709">Base#reset_column_information</a> in order to
ensure that the model has the latest column data from after the new column
was added. Example:
</p>
<pre>
  class AddPeopleSalary &lt; ActiveRecord::Migration
    def self.up
      add_column :people, :salary, :integer
      Person.reset_column_information
      Person.find(:all).each do |p|
        p.update_attribute :salary, SalaryCalculator.compute(p)
      end
    end
  end
</pre>
<h2>Controlling verbosity</h2>
<p>
By default, migrations will describe the actions they are taking, writing
them to the console as they happen, along with benchmarks describing how
long each step took.
</p>
<p>
You can quiet them down by setting ActiveRecord::Migration.verbose = false.
</p>
<p>
You can also insert your own messages and benchmarks by using the <tt><a
href="Migration.html#M001671">say_with_time</a></tt> method:
</p>
<pre>
  def self.up
    ...
    say_with_time &quot;Updating salaries...&quot; do
      Person.find(:all).each do |p|
        p.update_attribute :salary, SalaryCalculator.compute(p)
      end
    end
    ...
  end
</pre>
<p>
The phrase &quot;Updating salaries&#8230;&quot; would then be printed,
along with the benchmark for the block when the block completes.
</p>
<h2>About the schema_migrations table</h2>
<p>
<a href="../Rails.html">Rails</a> versions 2.0 and prior used to create a
table called <tt>schema_info</tt> when using migrations. This table
contained the version of the schema as of the last applied migration.
</p>
<p>
Starting with <a href="../Rails.html">Rails</a> 2.1, the
<tt>schema_info</tt> table is (automatically) replaced by the
<tt>schema_migrations</tt> table, which contains the version numbers of all
the migrations applied.
</p>
<p>
As a result, it is now possible to add migration files that are numbered
lower than the current schema version: when migrating up, those
never-applied &quot;interleaved&quot; migrations will be automatically
applied, and when migrating down, never-applied &quot;interleaved&quot;
migrations will be skipped.
</p>
<h2>Timestamped Migrations</h2>
<p>
By default, <a href="../Rails.html">Rails</a> generates migrations that
look like:
</p>
<pre>
   20080717013526_your_migration_name.rb
</pre>
<p>
The prefix is a generation timestamp (in UTC).
</p>
<p>
If you&#8216;d prefer to use numeric prefixes, you can turn timestamped
migrations off by setting:
</p>
<pre>
   config.active_record.timestamped_migrations = false
</pre>
<p>
In environment.rb.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001669">announce</a>&nbsp;&nbsp;
      <a href="#M001673">method_missing</a>&nbsp;&nbsp;
      <a href="#M001667">migrate</a>&nbsp;&nbsp;
      <a href="#M001670">say</a>&nbsp;&nbsp;
      <a href="#M001671">say_with_time</a>&nbsp;&nbsp;
      <a href="#M001672">suppress_messages</a>&nbsp;&nbsp;
      <a href="#M001668">write</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M001669" class="method-detail">
        <a name="M001669"></a>

        <div class="method-heading">
          <a href="#M001669" class="method-signature">
          <span class="method-name">announce</span><span class="method-args">(message)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001669-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001669-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/migration.rb, line 313</span>
313:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">announce</span>(<span class="ruby-identifier">message</span>)
314:         <span class="ruby-identifier">text</span> = <span class="ruby-node">&quot;#{@version} #{name}: #{message}&quot;</span>
315:         <span class="ruby-identifier">length</span> = [<span class="ruby-value">0</span>, <span class="ruby-value">75</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">length</span>].<span class="ruby-identifier">max</span>
316:         <span class="ruby-identifier">write</span> <span class="ruby-value str">&quot;== %s %s&quot;</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">text</span>, <span class="ruby-value str">&quot;=&quot;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">length</span>]
317:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001673" class="method-detail">
        <a name="M001673"></a>

        <div class="method-heading">
          <a href="#M001673" class="method-signature">
          <span class="method-name">method_missing</span><span class="method-args">(method, *arguments, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001673-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001673-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/migration.rb, line 339</span>
339:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
340:         <span class="ruby-identifier">arg_list</span> = <span class="ruby-identifier">arguments</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:inspect</span>) <span class="ruby-operator">*</span> <span class="ruby-value str">', '</span>
341: 
342:         <span class="ruby-identifier">say_with_time</span> <span class="ruby-node">&quot;#{method}(#{arg_list})&quot;</span> <span class="ruby-keyword kw">do</span>
343:           <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">arguments</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">method</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:execute</span>
344:             <span class="ruby-identifier">arguments</span>[<span class="ruby-value">0</span>] = <span class="ruby-constant">Migrator</span>.<span class="ruby-identifier">proper_table_name</span>(<span class="ruby-identifier">arguments</span>.<span class="ruby-identifier">first</span>)
345:           <span class="ruby-keyword kw">end</span>
346:           <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
347:         <span class="ruby-keyword kw">end</span>
348:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001667" class="method-detail">
        <a name="M001667"></a>

        <div class="method-heading">
          <a href="#M001667" class="method-signature">
          <span class="method-name">migrate</span><span class="method-args">(direction)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Execute this migration in the named direction
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001667-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001667-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/migration.rb, line 271</span>
271:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">migrate</span>(<span class="ruby-identifier">direction</span>)
272:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">direction</span>)
273: 
274:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">direction</span>
275:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:up</span>   <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">announce</span> <span class="ruby-value str">&quot;migrating&quot;</span>
276:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:down</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">announce</span> <span class="ruby-value str">&quot;reverting&quot;</span>
277:         <span class="ruby-keyword kw">end</span>
278: 
279:         <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">nil</span>
280:         <span class="ruby-identifier">time</span> = <span class="ruby-constant">Benchmark</span>.<span class="ruby-identifier">measure</span> { <span class="ruby-identifier">result</span> = <span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{direction}_without_benchmarks&quot;</span>) }
281: 
282:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">direction</span>
283:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:up</span>   <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">announce</span> <span class="ruby-value str">&quot;migrated (%.4fs)&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">time</span>.<span class="ruby-identifier">real</span>; <span class="ruby-identifier">write</span>
284:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:down</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">announce</span> <span class="ruby-value str">&quot;reverted (%.4fs)&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">time</span>.<span class="ruby-identifier">real</span>; <span class="ruby-identifier">write</span>
285:         <span class="ruby-keyword kw">end</span>
286: 
287:         <span class="ruby-identifier">result</span>
288:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001670" class="method-detail">
        <a name="M001670"></a>

        <div class="method-heading">
          <a href="#M001670" class="method-signature">
          <span class="method-name">say</span><span class="method-args">(message, subitem=false)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001670-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001670-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/migration.rb, line 319</span>
319:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">say</span>(<span class="ruby-identifier">message</span>, <span class="ruby-identifier">subitem</span>=<span class="ruby-keyword kw">false</span>)
320:         <span class="ruby-identifier">write</span> <span class="ruby-node">&quot;#{subitem ? &quot;   -&gt;&quot; : &quot;--&quot;} #{message}&quot;</span>
321:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001671" class="method-detail">
        <a name="M001671"></a>

        <div class="method-heading">
          <a href="#M001671" class="method-signature">
          <span class="method-name">say_with_time</span><span class="method-args">(message) {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001671-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001671-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/migration.rb, line 323</span>
323:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">say_with_time</span>(<span class="ruby-identifier">message</span>)
324:         <span class="ruby-identifier">say</span>(<span class="ruby-identifier">message</span>)
325:         <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">nil</span>
326:         <span class="ruby-identifier">time</span> = <span class="ruby-constant">Benchmark</span>.<span class="ruby-identifier">measure</span> { <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">yield</span> }
327:         <span class="ruby-identifier">say</span> <span class="ruby-value str">&quot;%.4fs&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">time</span>.<span class="ruby-identifier">real</span>, <span class="ruby-identifier">:subitem</span>
328:         <span class="ruby-identifier">say</span>(<span class="ruby-node">&quot;#{result} rows&quot;</span>, <span class="ruby-identifier">:subitem</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>)
329:         <span class="ruby-identifier">result</span>
330:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001672" class="method-detail">
        <a name="M001672"></a>

        <div class="method-heading">
          <a href="#M001672" class="method-signature">
          <span class="method-name">suppress_messages</span><span class="method-args">() {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001672-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001672-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/migration.rb, line 332</span>
332:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">suppress_messages</span>
333:         <span class="ruby-identifier">save</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">verbose</span> = <span class="ruby-identifier">verbose</span>, <span class="ruby-keyword kw">false</span>
334:         <span class="ruby-keyword kw">yield</span>
335:       <span class="ruby-keyword kw">ensure</span>
336:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">verbose</span> = <span class="ruby-identifier">save</span>
337:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001668" class="method-detail">
        <a name="M001668"></a>

        <div class="method-heading">
          <a href="#M001668" class="method-signature">
          <span class="method-name">write</span><span class="method-args">(text=&quot;&quot;)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001668-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001668-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/migration.rb, line 309</span>
309:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">text</span>=<span class="ruby-value str">&quot;&quot;</span>)
310:         <span class="ruby-identifier">puts</span>(<span class="ruby-identifier">text</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">verbose</span>
311:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>